//
//  RegistPwdController.m
//  Safflower
//
//  Created by 袁亮 on 2016/12/13.
//  Copyright © 2016年 Migic_Z. All rights reserved.
//

#import "RegistPwdController.h"
#import "RegistPwdView.h"
#import "UserDataCenter.h"

@interface RegistPwdController ()<RegistPwdViewDelegate>

@property (nonatomic, strong) RegistPwdView *pwdView;
@property (nonatomic, strong) UserDataCenter *dataCenter;

@end

@implementation RegistPwdController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.baseTitle = @"设置密码";
    self.rightBtnTitle = @"返回";
    
    _dataCenter = [UserDataCenter new];
    
    [self makeRegistPwdView];
}

- (void)makeRegistPwdView
{
    _pwdView = [RegistPwdView new];
    _pwdView.delegate = self;
    [self.baseView addSubview:_pwdView];
    [_pwdView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.mas_equalTo(0);
    }];
}

- (void)clickTrueWithPwd:(id)password
{
    if ([password integerValue] == 0) {
        [YJProgressHud showErrorHud:@"必须设置密码哦"];
    }else if ([password integerValue] == 1){
        [YJProgressHud showErrorHud:@"两次密码不一致"];
    }else{
        [YJProgressHud showLoadingHud:@"注册中"];
        [_dataCenter regsitAccountWithUser:self.user password:(NSString *)password complation:^(id error) {
            if (error == nil) {
                [YJProgressHud showSuccessHud:@"注册成功"];
                [self dismissViewControllerAnimated:NO completion:nil];
            }else{
                [YJProgressHud showErrorHud:(NSString *)error];
            }
        }];
    }
}

- (void)clickRightButton
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
